<?php	ob_start();
   include '../includes/session.php';
 include '../includes/constants.php';
 include '../includes/functions.php';
  include_once '../includes/allstripslashes.php';

 include '../mail.php';

 $partners=new partners;
 $partners->connection($host,$user,$pass,$db);

$merid=$_GET['id'];
$actionflag=$_GET['mode'];
//echo "$actionflag";
$sql="select * from partners_merchant where merchant_id=$merid";
$res=mysql_query($sql);

/// check is submitted to remove;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Affiliate Network Pro - Admin Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="admin.css" />
</head>
<body bgcolor="#FFFFFF" <?=$body_onload?>>
<!-- ImageReady Slices (admin.psd) -->
<table width="400" border='0' align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td height="69">
<script language="javascript" type="text/javascript">



function button1_onclick() {
window.close();
}

</script>
<?


if($rbtn=="Remove" || $rbtn=="Reject")
        {
                  $sql="select * from partners_login where login_id=$toremove and login_flag='m'";
                  $ret1=mysql_query($sql);
                  $row=mysql_fetch_object($ret1);
                  $to=$row->login_email;

                 //$sql="delete from partners_merchant where merchant_id='$toremove'";
                 //mysql_query($sql) or die('cant exe');
        ?>
                <div align="center">
             <P>&nbsp;&nbsp;</p>
            <P>&nbsp;&nbsp;</p>

            <big><? if($rbtn=="Remove")
            {
            $sql="SELECT  * FROM partners_merchant a, partners_joinpgm c, partners_transaction d" ;
            $sql =$sql." WHERE merchant_id =$toremove and d.transaction_joinpgmid = c.joinpgm_id AND c.joinpgm_merchantid = a.merchant_id";
            $result=mysql_query($sql);
            if(mysql_num_rows($result))
                echo "Can't Remove This Merchant";
            else
               {
                	$sql="delete from partners_merchant where merchant_id='$toremove'";
                     mysql_query($sql) or die('cant exe');
                	$sql="delete from partners_login where login_id='$toremove' and login_flag='m'";
                     mysql_query($sql) or die('cant exe');
                	MailEvent("Remove Merchant",0,0,$to,0 )  ;
               		 echo "Merchant Removed From This Site !!!";
              }
            }
            else
            {
            $sql="delete from partners_merchant where merchant_id='$toremove'";
                 mysql_query($sql) or die('cant exe');

             MailEvent("Reject Merchant",0,0,$to,0 )  ;
            echo "Merchant Rejected From This Site !!!";
            }
            ?></big><br/>


            <P>&nbsp;&nbsp;</p>
                         <input id="button1"  type="button" align="center" value="CLOSE" name="button1" onclick="return button1_onclick()" />
                    </div>
        <?
       exit;

}


 while($row=mysql_fetch_object($res)){



         $merchant_id=$row->        merchant_id;
         $merchant_firstname=$row->merchant_firstname;
         $merchant_lastname=$row->merchant_lastname;
         $merchant_company=$row->merchant_company;
         $merchant_address=$row->merchant_address;
         $merchant_city=$row->merchant_city;
         $merchant_country=$row->merchant_country;
         $merchant_phone=$row->merchant_phone;
         $merchant_url=$row->merchant_url;
         $merchant_category=$row->merchant_category;
         $merchant_status=$row->merchant_status;
         $merchant_date=$row->merchant_date;
         $merchant_fax=$row->merchant_fax;

                }



//echo $merid."ok";






?>


<table border='0' class="tablebdr" cellpadding="0" cellspacing="5" width="85%" id="AutoNumber1">
  <tr>
    <td colspan="5" height="19">
    <p align="center" class="textred">Do You Really Want To <?=$actionflag?> This Merchant ?</p></td>
  </tr>
  <tr>
  	<td align="center" colspan="5" >
    	<form name="FormName" action="remove_merchant.php" method="post">
        <table border='0'  cellpadding="0" cellspacing="0" width="100%">
           <tr>
            <td width="100%" height="10" colspan="5" class="tdhead" align="center">
	            <input type="submit" name="rbtn" value="<?=$actionflag?>"/>
	            <input name="toremove" type="hidden" value="<?=$merid?>" />
	            <input id="button1"  type="button" value="Close" name="button1" onclick="return button1_onclick()"/>
	        </td>
           </tr>
        </table>
        </form>
    </td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">ID</td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19"><?=$merchant_id?></td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">Company Name</td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19"><?=$merchant_company?></td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">First Name</td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19"><?=$merchant_firstname?></td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">
    <p align="left">Last Name</p></td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19"><?=$merchant_lastname?></td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">Address</td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19">
    <p>
      <textarea rows="2" name="add" cols="20"><?=$merchant_address?></textarea></p>
    </td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="17"></td>
    <td width="38%" height="17">&nbsp;City</td>
    <td width="1%" height="17"><b>:</b></td>
    <td width="60%" height="17"><?=$merchant_city?></td>
    <td width="1%" height="17"></td>
  </tr>
  <tr>
    <td width="2%" height="17"></td>
    <td width="38%" height="17">Country</td>
    <td width="1%" height="17"><b>:</b></td>
    <td width="60%" height="17"><?=$merchant_country?> </td>
    <td width="1%" height="17"></td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">Phone</td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19"><?=$merchant_phone?></td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">URL</td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19"><?=$merchant_url?></td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">Category</td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19"><?=$merchant_category?></td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="19">&nbsp;</td>
    <td width="38%" height="19">Status</td>
    <td width="1%" height="19"><b>:</b></td>
    <td width="60%" height="19"><?=$merchant_status?></td>
    <td width="1%" height="19">&nbsp;</td>
  </tr>
  <tr>
    <td width="2%" height="11"></td>
    <td width="38%" height="11">Date of Joining</td>
    <td width="1%" height="11"><b>:</b></td>
    <td width="60%" height="11"><?=$merchant_date ?></td>
    <td width="1%" height="11"></td>
  </tr>
  <tr>
    <td width="2%" height="15"></td>
    <td width="38%" height="15">Fax</td>
    <td width="1%" height="15"><b>:</b></td>
    <td width="60%" height="15"><?=$merchant_fax?></td>
    <td width="1%" height="15"></td>
  </tr>
</table>
</td></tr>
</table>

</body>

</html>